package com.zsl.swing.redis.desktop.pool;

import java.util.concurrent.*;

public class ThreadPoolUtils {

    private static final int CORE_SIZE = Runtime.getRuntime().availableProcessors();

    private static final ThreadPoolExecutor pool = new ThreadPoolExecutor(CORE_SIZE, CORE_SIZE * 2, 10L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1024));

    public static void execute(Runnable runnable){
        pool.execute(runnable);
    }

    public static <T> Future<T> execute(Callable<T> callable){
        return pool.submit(callable);
    }
}
